<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>
        <li>123</li>
        <li>123</li>
        <li>123</li>
        <li>123</li>
    </ul>
    <script>
        let lis=document.querySelectorAll('li');

        let map=new Map();
        map.set(lis[0],'red');
        map.set(lis[1],'blue');
        map.set(lis[2],'yellow');
        map.set(lis[3],'green');

        map.forEach((item,key)=>{
            key.style.color=item;
        })
    </script>
</body>
</html>